/**
 * GameTask.java
 * com.game.task.model
 * Copyright (c) 2016, 北京聚智未来科技有限公司版权所有.
*/

package com.game.task.model;

import java.util.List;

import com.eova.common.base.BaseModel;
import com.jfinal.plugin.activerecord.Db;

/**
 * 游戏-任务
 * <p>
 * @author   wxl
 * @Date	 2016年12月12日 	 
 */
public class GameTask extends BaseModel<GameTask> {

	private static final long serialVersionUID = 1500432802093512361L;

	public static final GameTask dao = new GameTask();

	/*
	 * 查询任务列表
	 */
	public List<GameTask> queryAll() {
		String sql = "SELECT * FROM game_task";
		return this.find(sql);
	}

	/*
	 * 任务详情
	 */
	public GameTask queryOne(String id) {
		String sql = "SELECT * FROM game_task t  WHERE  t.id = ?";
		return this.findFirst(sql, id);
	}

	/* 领取任务奖励
	 * @param userid 用户id
	 * @param id 任务id
	 */
	public int addTaskGold(String userId, String id) {
		String sql = "update `demo`.user_account_info set balance = balance + (select taskGold from `demo`.game_task where id=?) where userId=?";
		return Db.update(sql, id, userId);
	}

}
